<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;
String admin_level = null;
String admin_ent_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	admin_level = userSession.getAdmin_level();
	admin_ent_id = userSession.getEnt_id();
}

String sel_ent_id 	= CommonUtil.nvl(request.getParameter("ent_id"),"");
String search_combo 	= CommonUtil.nvl(request.getParameter("search_combo"),"");
String keyword 		= CommonUtil.nvl(request.getParameter("keyword"),"");
String line_number	= CommonUtil.nvl(request.getParameter("line_number"),"10");
//페이징 처리 Start
//페이지 표시정보 받기 혹은 검색입력창
String curr_page = CommonUtil.nvl(request.getParameter("curr_page"),"1");

String one_group = CommonUtil.nvl(request.getParameter("one_group"),"10");
String total_count = CommonUtil.nvl(request.getParameter("total_count"),"0");
//페이징 처리 End

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;

String member_id 		= "";
String ent_id 		= "";
String login_id_map 		= "";
String login_name 	= "";
String soc_no 		= "";
String email 	= "";
String tel_no	= "";
String cell_no	= "";
String ent_nm	= "";
String reg_dt	= "";
String addr	= "";
String detail_addr	= "";
String post_no	= "";
String etc	= "";
String r_num="";


if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

if(list != null){
	if(list.size() > 0){
		total_count = (String)((HashMap)list.get(0)).get("total_row");
		System.out.println("total_count ========> " + total_count);
	}
}

if(list.size() == 0){
	total_count = "0";
}

%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script>
function go_input(){
	var frm = document.mainform;	
	frm.cmd.value='member_input';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}

function go_modify(ad){
	var frm = document.mainform;
	frm.member_id.value= ad
	
	frm.cmd.value='member_select';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}

function go_delete(ad){
	var frm = document.mainform;	
	frm.member_id.value= ad
	
	if(confirm('삭제하시겠습니까?')){
		frm.cmd.value='member_delete';
		frm.action = '/speaking.pb';
		frm.target= 'hidden_frm';              
		frm.submit();	
	}
}

function go_member(){
	var frm = document.mainform;	
	frm.cmd.value='member_main';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}

//검색
function go_search(){
	var frm = document.mainform;
	/*
	if(frm.search_combo.value==''){
		alert('검색구분을 선택하세요.');
		return;
	}
	*/
	frm.cmd.value='member_main';
	frm.curr_page.value ="1";
	frm.total_count.value="0";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

function go_excel(){
	var frm = document.mainform;	
	//frm.cmd.value='member_main';
	frm.action = '/jsp/sp_sp0601_excel.jsp';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

// 페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainform;
	frm.cmd.value='member_main';
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.keyword.value = "<%=keyword%>";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

<%if(!admin_level.equals("5")){ %>
function init_member(){
	form = document.mainform;
	setSPSelect(form.ent_id,'<%=sel_ent_id%>', '기업선택', 'ent');
}
window.onload = init_member;
<%}%>
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="member_main" /><jsp:param name="submenu_idx" value="1" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" >
	<div id="bodyContainer">
        <div id="contents">
          <jsp:include page="/jsp/common/submenu_list.jsp"><jsp:param name="submenu_id" value="member_main" /><jsp:param name="submenu_idx" value="1" /></jsp:include>
          <div class="select_menu">
            <ul>              
              <li>
              <%if(!admin_level.equals("5")){ %>
              <select name="ent_id" id="ent_id">
                  <option value=''>기업선택</option>
              </select>
              <%}else{ %>
              <input type="hidden" name="ent_id" value="<%=admin_ent_id %>">
              <%} %>
              </li>
              <li><select name="search_combo" id="search_combo">
                <option value=''>선택</option>
                <option value=1>이름</option>
                <option value=2>등급</option>
              </select></li>
              <li><input type="text" name="keyword" id="keyword" style="width:200px"/></li>
              <li><a href="#" onclick="go_search()"><img src="/img/btn_search.gif" alt="search" /></a></li>
              <li><a href="#" onclick="go_excel()"><img src="/img/btn_excel.gif" alt="excel" /></a></li>
            </ul>
          </div>
          
          <div class="boxContainer">
            <dl title="회원목록">
              <dt>회원목록 [Total : <font style="color:red"><%=total_count %></font>]</dt>
            </dl>
            <table class="listTb">
              <tr>
                <th>번호</th>
                <th>&nbsp;이름</th>
                <th>아이디&nbsp;</th>
                <th>소속&nbsp;</th>
                <th>email&nbsp;</th>
                <th>등록일&nbsp;</th>
                <th>관리</th>                
              </tr>
<%              

    if (list!=null && list.size()> 0) {
    	for(int i=0; i<list.size(); i++){
	      map=(HashMap)list.get(i); 
	      r_num = CommonUtil.nvl((String)map.get("r_num"));
	      member_id = CommonUtil.nvl((String)map.get("member_id"));
	      ent_id = CommonUtil.nvl((String)map.get("ent_id"));
	      ent_nm = CommonUtil.nvl((String)map.get("ent_nm"));
	      login_id_map = CommonUtil.nvl(Crypto.DecodeBySType((String)map.get("login_id")));
	      login_name = CommonUtil.nvl((String)map.get("login_name"));
	      
	      soc_no = CommonUtil.nvl((String)map.get("soc_no"));
	      email = CommonUtil.nvl((String)map.get("email"));
	      tel_no = CommonUtil.nvl((String)map.get("tel_no"));
	      cell_no = CommonUtil.nvl((String)map.get("cell_no"));
	      reg_dt = CommonUtil.nvl((String)map.get("reg_dt"));
%>
			<tr>
                <td><%=r_num %></td>
                <td><%=login_name %></td>
                <td><%=login_id_map %></td>
                <td><%=ent_nm %></td>
                <td><%=email %></td>
                <td><%=reg_dt %></td>
                <td><a href="#" onclick="go_modify('<%=member_id%>')"><img src="img/btn_mmm.gif" width="16" height="14" alt="manage" /></a> <a href="#" onclick="go_delete('<%=member_id%>')"><img src="img/btn_ddd.gif" width="16" height="14" alt="delete" /></a></td>
              </tr>
<%	      
    	}
      
    }else{

%> 
    				<tr>
    	                <td colspan=9 align=center>등록된 회원가 없습니다.</td>
    	            </tr>
<%
   }
%>
            </table>
            
            <!-- 
            <div class="paging"><a href="#"><img src="img/bt_pprev.gif" alt="이전" /></a><a href="#"><img src="img/bt_prev.gif" alt="이전" /></a><a href="#" class="on">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a><a href="#"><img src="img/bt_next.gif" alt="이전" /></a><a href="#"><img src="img/bt_nnext.gif" alt="이전" /></a></div>
             -->
            <!-- 페이징 -->
            <div class="paging"><common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=line_number%>" oneGroup="<%=one_group%>"/></div>
            <!-- //페이징 -->
           
            <p class="a_r"><a href="#" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" width="49" height="20" /></a>&nbsp;&nbsp; </p>
            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="member_id" value="">
<input type="hidden" name="line_number" value="<%=line_number%>">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
